<template>
  <Card title="风采列表">
    <Table border stripe ref="selection" size="small" :columns="columns" :data="nowData">
      <template slot-scope="{ row, index }" slot="action">
        <Button type="primary" size="small" style="margin-right: 5px" @click="show(row)">查看</Button>
        <Button type="error" size="small" @click="remove(row)">删除</Button>
        <Modal
          v-model="modal1"
          title="提示"
          @on-ok="okDel"
          @on-cancel="cancel">
          <p>确定要删除此信息吗?删除后将不能恢复</p>
        </Modal>
      </template>
    </Table>
    <Page :total="dataCount" :page-size="queryThearBO.size" @on-change="changepage" @on-page-size-change="_nowPageSize"
          show-total show-sizer show-elevator/>
  </Card>
</template>

<script>
export default {
  name: 'thear-list',
  data () {
    return {
      delRow: {},
      modal1: false,
      columns: [
        {
          title: '序号',
          key: 'cuThearId'
        },
        {
          title: '标题',
          key: 'cuThearTitle'
        },
        {
          title: '时间',
          key: 'cuThearDate'
        },
        {
          title: '操作',
          slot: 'action',
          width: 150,
          align: 'center'
        }
      ],
      nowData: [],
      queryThearBO: {
        cuTownId: this.$store.state.user.userAll.cuOnlyId,
        size: 10, // 每页显示多少条
        current: 1// 当前页
      },

      dataCount: 0// 总条数

    }
  },
  methods: {
    show (row) {
      this.$router.push('/thear/thear_add/' + row.cuThearId)
    },
    remove (row) {
      this.delRow = row
      this.modal1 = true
    },
    okDel () {
      this.$axios_supermall.post('/thear/deleteId', this.delRow.cuThearId).then(resp => {
        if (resp.data.code == 0) {
          this.$Message.info('删除成功')
          this.query()
        }
      })
    },
    cancel () {
      this.$Message.info('取消删除')
    },
    changepage (index) {
      this.queryThearBO.current = index
      this.query()
    },
    _nowPageSize (index) {
      // 实时获取当前需要显示的条数
      this.queryThearBO.size = index
    },
    query () {
      this.$Loading.start()
      this.$axios_supermall.post('/thear/queryPage', this.queryThearBO).then(resp => {
        if (resp.data.code == 0) {
          let data = resp.data.data
          this.nowData = data.records
          this.queryThearBO.current = data.current
          this.queryThearBO.size = data.size
          this.dataCount = data.total
        }
        this.$Loading.finish()
      }).catch(() => {
        this.$Loading.error()
      })
    }
  },
  mounted () {
    this.query()
  }
}
</script>

<style scoped>

</style>
